﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public static class ContractsExtensions
{
    public static void ThrowIfNull(this object source, string parameterName)
    {
        if (source != null) return;

        if (!String.IsNullOrWhiteSpace(parameterName)) throw new ArgumentNullException(parameterName);

        throw new ArgumentNullException();
    }

    public static void ThrowIfNull(this object source, string parameterName, string message)
    {
        if (source != null) return;

        if (!String.IsNullOrWhiteSpace(parameterName))
        {
            if (!String.IsNullOrWhiteSpace(message)) throw new ArgumentNullException(parameterName, message);

            throw new ArgumentNullException(parameterName);
        }

        throw new ArgumentNullException();
    }
}